﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Demo.ServiceContracts.DataContracts;

namespace Demo.ServiceImplementation
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class NotificationService :  ServiceContracts.INotificationService
    {
        public HashSet<ServiceContracts.INotificationClient> _Suscribers = new HashSet<ServiceContracts.INotificationClient>(); 
        public void RegisterListerner()
        {
            var call = OperationContext.Current.GetCallbackChannel<ServiceContracts.INotificationClient>();
            _Suscribers.Add(call);    
        }
        public void SendNotification(string from, string message, DCClient cl)
        {
            foreach (var item in this._Suscribers)
            {
                item.ReciveNotification(from, message, cl);                 
            }
        }
    }
}
